<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String xm_id = request.getParameter("xm_id") == null ? "" : request.getParameter("xm_id");
    int flag = 1;

%>
<script type="text/javascript">
<!--
var isShow=<%=request.getParameter("isShow")%>;
//-->
</script>
<html>
	<head>
		<title>查看详情</title>
		<link  rel="stylesheet"  href  ="<%=contextPath%>/public/swfupload/css/swfupload.css">
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
			}
			.tdg{
			padding-top:10px;
			padding-bottom:5px;
			font-size: 12px;
			background-color: #c0ebd7;
			width:20%;
		}
		.tdb{
			padding:5px;
			width:30%;
		}
		</style>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/datastructs.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/sys.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/prototype.js"  ></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/attachMenu.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/Menu.js"></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/fileprogress.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/handlers.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.queue.js"  ></script>
		<script type="text/javascript">
		
			jQuery(document).ready(function() {
				
			
					jQuery('#xmForm').form({
						onLoadSuccess:function(){
						    loadGDSets();
							queueCompleteOver();
						}
					});
				   jQuery('#xmForm').form('load','<%=contextPath%>/springMVC/xm/getXM?xm_id=<%=request.getParameter("xm_id")%>');
			
				
            jQuery('#customer_id').combogrid({
					title:'客户选择',
					mode:"remote",
					loadMsg:'正在加载数据，请稍后......',
					panelWidth:550,
					panelHeight:400,
					url:"<%=contextPath%>/springMVC/crm/listPageCustomer",
					idField:"id",
					textField:"company",
					rownumbers:true,
					fitColumns:true,
					columns: [[
						{field:'id',hidden:true},
						{title:'客户类别',field:'type_name',width:200,align:'center'},
						{title:'公司名称',field:'company',width:200,align:'center'},
						{title:'联系人',field:'contact',width:200,align:'center'},
						{title:'TEL',field:'tel',width:200,align:'center'}
					]],
					toolbar:"#tbc",
					pageSize:10,
					pageList:[10,50,100],  
					pagination:true,
					onChange:function(){
						var row = jQuery('#customer_id').combogrid("grid").datagrid('getSelected');
						jQuery('#customer_linkman').val(row.contact);
						jQuery('#linkman_phone').val(row.tel);
					}
				});
         
			jQuery('#admin_id').combogrid({
					title:'人员选择',
					mode:"remote",
					loadMsg:'正在加载数据，请稍后......',
					panelWidth:550,
					panelHeight:400,
					url:"<%=contextPath%>/springMVC/group/listPageUser",
					idField:"id",
					textField:"truename",
					rownumbers:true,
					fitColumns:true,
					columns: [[
						{field:'id',hidden:true},
						{field:'deptId',hidden:true},
						{field:'truename',title:'姓名',width:100},
						{field:'deptName',title:'所属部门',width:100},
						{field:'privName',title:'角色',width:100}
					]],
					toolbar:"#tb",
					pageSize:10,
					pageList:[10,50,100],  
					pagination:true,
					onChange:function(){
						var row = jQuery('#admin_id').combogrid("grid").datagrid('getSelected');
						jQuery('#admin_dept_id').val(row.deptId);
						jQuery('#admin_dept').val(row.deptName);
					}
				});
				var settings = {
				      flash_url : "<%=contextPath%>/public/swfupload/swfupload.swf",
				      upload_url: "<%=contextPath%>/springMVC/fileUpload/fileupload",
				      post_params: {
				    	 "module" : "<%=com.beaut.project.util.StaticData.XM_MODULE%>"
				      },
				      file_size_limit : "100 MB",
				      file_types : "*.*",
				      file_types_description : "All Files",
				      file_upload_limit : 100,
				      file_queue_limit : 0,
				      custom_settings : {
				        uploadArea : "fsUploadArea",
				        progressTarget : "fsUploadProgress",
				        startButtonId : "btnStart",
				        cancelButtonId : "btnCancel"
				      },
				      debug: false,
				      button_image_url: "<%=contextPath%>/public/swfupload/img/uploadx4.gif",
				      button_width: "65",
				      button_height: "29",
				      button_placeholder_id: "spanButtonUpload",
				      button_text: '<span class=\"textUpload\">上传附件</span>',
				      button_text_style: ".textUpload{color:#0000ff;}",
				      button_text_top_padding : 1,
				      button_text_left_padding : 18,
				      button_width: 80,
				      button_height: 20,
				      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				      button_cursor: SWFUpload.CURSOR.HAND,
				      
				      file_queued_handler : fileQueued,
				      file_queue_error_handler : fileQueueError,
				      file_dialog_complete_handler : fileDialogComplete,
				      upload_start_handler : uploadStart,
				      upload_progress_handler : uploadProgress,
				      upload_error_handler : uploadError,
				      upload_success_handler : uploadSuccessOver,
				      upload_complete_handler : uploadComplete,
				      queue_complete_handler : queueCompleteOver
				    };
				    swfupload = new SWFUpload(settings);
			   });

				    
		function queueCompleteOver(){

			var attachmentIds = $("attachmentId").value;
		    var attachmentNames = $("attachmentName").value;
		    if(attachmentIds){
		      jQuery('#attaTr').show();
	       	  jQuery('#fsUploadArea').hide();
	       	  attachMenuUtil("showAtt",null,null,attachmentNames,attachmentIds,true,'attach');

		    }
		    

		 }
		function loadGDSets(){
			var gdIds = $("gdIds").value;
		    var gdNames = $("gdNames").value;
			rtCallBackGDSet(gdIds,gdNames);
	
			
		}	

		 function uploadSuccessOver(file, serverData){
				  try {
				    var progress = new FileProgress(file, this.customSettings.progressTarget);
				    progress.toggleCancel(false);
				    var json = null;
				    json = serverData.evalJSON();
				    if(json.rtState=="1") {
				       progress.setError();
				       progress.setStatus("上传失败");
				    } else {
				       if($('attachmentId').value!=null && $('attachmentId').value!=""){
				    	 $('attachmentId').value += ',' + json.rtData.attachmentId;
				       } 
				       else{
				    	   $('attachmentId').value = json.rtData.attachmentId;
				       }
				       if($('attachmentName').value!=null && $('attachmentName').value!=""){
				    	 $('attachmentName').value += '*' + json.rtData.attachmentName;
				       } 
				       else{
				    	   $('attachmentName').value = json.rtData.attachmentName;
				       }
				    }
				  } catch (ex) {
				    this.debug(ex);
				  }
		}
		 			 
		  function deleteAttachment(attachmentId,attachmentName){
			  var attrIds = $("attachmentId").value;
		    var attrNames = $("attachmentName").value;
		     var attrIdArrays = attrIds.split(",");
			  var attrNameArrays = attrNames.split("*");
			 var idArray = new Array();
			 var nameArray = new Array();
			 
			 for(var i=0;i<attrIdArrays.length;i++){
				 if(attrIdArrays[i] != attachmentId){
					 idArray.push(attrIdArrays[i]);
					 nameArray.push(attrNameArrays[i]);
				 }
			 }
			 $("attachmentId").value = idArray.join(",");
			 $("attachmentName").value = nameArray.join("*");
			 if($("attachmentId").value == ""){
				 jQuery('#attaTr').hide();
			 }
		  }
		  
		   
		function addGDSet(){
			openDialogResize('<%=contextPath %>/springViews/xm/gdSetSelect.jsp',1000, 800);
		}
		function rtCallBackGDSet(ids,names){
			  if(ids==""){
				  return;
			  }
			  var keys= new Array(); 
			  var values= new Array(); 
              keys=ids.split(",");
              values=names.split(",");
			    for (i=0;i<keys.length ;i++ )   
			    {   
			        jsAddItemToSelect(document.getElementById("gdset"),values[i],keys[i]);

			    }   
			
		}
		function jsSelectIsExitItem(objSelect, objItemValue) {        
		    var isExit = false;        
		    for (var i = 0; i < objSelect.options.length; i++) {        
		        if (objSelect.options[i].value == objItemValue) {        
		            isExit = true;        
		            break;        
		        }        
		    }        
		    return isExit;        
		}         
   
		// 2.向select选项中 加入一个Item        
		function jsAddItemToSelect(objSelect, objItemText, objItemValue) {        
		    //判断是否存在        
		    if (jsSelectIsExitItem(objSelect, objItemValue)) {        
		       // alert("该Item的Value值已经存在");        
		    } else {        
		        var varItem = new Option(objItemText, objItemValue);      
		        objSelect.options.add(varItem);     
		         
		    }        
		}  
		// 4.删除select中选中的项    
		function jsRemoveSelectedItemFromSelect(objSelect) {        
		    var length = objSelect.options.length - 1;    
		    for(var i = length; i >= 0; i--){    
		        if(objSelect[i].selected == true){    
		            objSelect.options[i] = null;    
		        }    
		    }    
		} 
		function clearSel(objSelect){
			objSelect.options.length = 0;  
		}
		 var subSelValues="";
		 var subSelTexts="";
		function getALLSubmitSelItems() {    
			subSelValues="";
			subSelTexts="";
			var objSelect=document.getElementById('gdset');
		         var len=objSelect.options.length;
		    for (var i = 0; i < len; i++) {  
		    	if(i==(len-1))
				{
						subSelValues+=objSelect.options[i].value;
					    subSelTexts+=objSelect.options[i].text;
				}else
				{
					subSelValues+=objSelect.options[i].value+",";
					subSelTexts+=objSelect.options[i].text+",";
					
				}
	       
		    }        
     
		}         
		</script>
	</head>
	<body>
		<form id="xmForm" method="post">
		<div style="width:90%;padding-left:50px;margin-top:20px" align="center">

						
							<table  style="border-collapse: collapse;" border="1px" width="100%" bordercolor="#0eb83a" >
							<tr>
									 <td align="right" nowrap class="td1">
										项目名称：
									</td>
									<td class="td2" nowrap colspan="3">
										<input id="xm_name" name="xm_name" style="width:90%" class="easyui-validatebox" data-options="required:true">
									</td>
									
								</tr>
						        <tr>
									 <td align="right" nowrap class="td1">
										项目编号：
									</td>
									<td class="td2" nowrap>
										<input id="xm_code" name="xm_code" class="easyui-validatebox" data-options="required:true">
									</td>
									<td align="right" nowrap class="td1">
										业务类别：
									</td>
									<td class="td2" nowrap >
										<input id=business_type  name="business_type">
									</td>
								</tr>
								 <tr>
									 <td align="right" nowrap class="td1">
										专业分类：
									</td>
									<td class="td2" nowrap>
										<input id="specialty_type" name="specialty_type" >
									</td>
									<td align="right" nowrap class="td1">
										专业明细：
									</td>
									<td class="td2" nowrap >
										<input id=specialty_detail  name="specialty_detail">
									</td>
								</tr>
								<tr>
								   <td align="right" nowrap class="td1">
										立项依据：
									</td>
									<td class="td2" nowrap >
										<input id="xm_depand_id"  name="xm_depand_id" class="easyui-combobox" data-options="required:true,valueField:'id',textField:'text',url:'<%=contextPath %>/springMVC/group/getSystemTypeBox?type=4'" /> 
									</td>
									 <td align="right" nowrap class="td1">
										管理公司：
									</td>
									<td class="td2" nowrap>
										<input id="manage_company" name="manage_company" data-options="required:true">
									</td>
						
								</tr>
								<tr>
								<td align="right" nowrap class="td1">
										客户：
									</td>
									<td class="td2" nowrap>
										<input id="customer_id" name="customer_id" data-options="required:true">
									</td>
								   <td align="right" nowrap class="td1">
										客户部门：
									</td>
									<td class="td2" nowrap >
										<input id="customer_dept"  name="customer_dept" data-options="required:true">
									</td>
									</tr>
								<tr>
									 <td align="right" nowrap class="td1">
										甲方负责人：
									</td>
									<td class="td2" nowrap>
										<input id="customer_linkman" name="customer_linkman" data-options="required:true">
									</td>
						            <td align="right" nowrap class="td1">
										负责人联系电话：
									</td>
									<td class="td2" nowrap>
										<input id="linkman_phone" name="linkman_phone" data-options="required:true">
									</td>
						
								</tr>
								
								<tr>
									<td align="right"  nowrap class="td1">
										项目负责人：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="admin_id" name="admin_id" data-options="required:true">
									</td>
									<td align="right"  nowrap class="td1">
										所属部门：
									</td>
									<td class="td2" nowrap >
										<input type="hidden" id="admin_dept_id" name="admin_dept_id">
										<input type="text" id="admin_dept" name="admin_dept" readOnly>
									</td>
								</tr>
								
								<tr>
									<td align="right"  nowrap class="td1">
										项目概况：
									</td>
									<td class="td2" nowrap colspan="3">
										<textarea id="xm_summary" name="xm_summary" class="easyui-validatebox" data-options="required:true" style="height:100%;width:100%" rows="6"></textarea>
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										实物工程量：
									</td>
									<td class="td2" nowrap colspan="3">
										<textarea id="quantities" name="quantities" class="easyui-validatebox" data-options="required:true" style="height:100%;width:100%" rows="6"></textarea>
									</td>
								</tr>
								<tr>
								<td align="right" nowrap class="td1">
										合同编号：
									</td>
									<td class="td2" nowrap >
										<input id=contract_code  name="contract_code" >
									</td>
									 <td align="right" nowrap class="td1">
										合同价：
									</td>
									<td class="td2" nowrap>
										<input id="contract_price" name="contract_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
						          
								</tr>
								<tr>
						            <td align="right" nowrap class="td1">
									预估结算（审定）价：
									</td>
									<td class="td2" nowrap>
	                                 <input id="estimate_balance_price" name="estimate_balance_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
									 <td align="right" nowrap class="td1">
										预估施工（劳务）费：
									</td>
									<td class="td2" nowrap>
										<input id="estimate_work_price" name="estimate_work_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
								</tr>
								<tr>
									
						            <td align="right" nowrap class="td1">
									预估材料采购费：
									</td>
									<td class="td2" nowrap>
	                                 <input id="estimate_material_price" name="estimate_material_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
									<td align="right" nowrap class="td1">
										预估其他费：
									</td>
									<td class="td2" nowrap>
										<input id="estimate_other_price" name="estimate_other_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
								</tr>	
						
									<tr>
						            <td align="right" nowrap class="td1">
									预估管理费：
									</td>
									<td class="td2" nowrap>
	                                 <input id="estimate_manage_price" name="estimate_manage_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
									<td align="right" nowrap class="td1">
									预估税费：
									</td>
									<td class="td2" nowrap>
	                                 <input id="estimate_tax_price" name="estimate_tax_price" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
								</tr>	
								<tr>
								<td align="right" nowrap class="td1">
										预算毛利：
									</td>
									<td class="td2" nowrap>
										<input id="estimate_grossprofit" name="estimate_grossprofit" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
						            <td align="right" nowrap class="td1">
									预算毛利率：
									</td>
									<td class="td2" nowrap>
	                                 <input id="estimate_grossprofit_rate" name="estimate_grossprofit_rate" class="easyui-numberbox" data-options="min:0,precision:2" value="0"/>
									</td>
								</tr>
								
								<tr>
								<td align="right" nowrap class="td1">
									包含工单：
									</td>
									<td  nowrap colspan="3">
									<input type="hidden" id="gdIds" name="gdIds">
								    <input type="hidden" id="gdNames" name="gdNames">
									<select name="gdset" class="exchangeSelect" multiple="" id="gdset" style="height:200px;width:100%" ></select>
																			
									</td>
						            
								</tr>	
																																									
									<tr id="attaTr" style="display:none">
								      <td nowrap class="td1">附件明细: </td>
								      <td class="td2" colspan='3'>
								        <input type="hidden" id="attachmentId" name="attachmentId">
								        <input type="hidden" id="attachmentName" name="attachmentName">
								        <span id="showAtt">
								        </span>
								      </td>
							   	    </tr>
							   	    <tr  style="display:none">
							      <td nowrap  align="right" class="td1">附件：</td>
							      <td class="td2" colspan='3'>
							        	 <div id="fsUploadArea" class="flash" style="width:380px;">
										     <div id="fsUploadProgress"></div>
										     <div>
										       <input type="button" id="btnStart" class="SmallButtonW" value="开始上传" onclick="swfupload.startUpload();" disabled="disabled">&nbsp;&nbsp;
										       <input type="button" id="btnCancel" class="SmallButtonW" value="全部取消" onclick="javascript:swfupload.cancelQueue();jQuery('#fsUploadArea').hide();" disabled="disabled">&nbsp;&nbsp;
										    </div>
									      </div>
									      
										    <div id="attachment1">
									          <span id="spanButtonUpload" title="上传附件"></span>
									        </div>
							      </td>
					   		   </tr>
				 			</table>	
		</div>
</form>
	</body>
</html>


